package com.neusoft.resturant.controller;


import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResOrder;
import com.neusoft.resturant.service.IResOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 订单Controller
 * 
 * @author zhengzijia0934
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/api/order")
public class ResOrderController
{
    @Autowired
    private IResOrderService resOrderService;

    /**
     * 查询订单列表
     */
    @GetMapping("/list")
    public R list(ResOrder resOrder)
    {
        List<ResOrder> list = resOrderService.selectResOrderList(resOrder);
        return R.success(list);
    }

    /**
     * 导出订单列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, ResOrder resOrder)
    {
        List<ResOrder> list = resOrderService.selectResOrderList(resOrder);
    }

    /**
     * 获取订单详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.success(resOrderService.selectResOrderById(id));
    }

    /**
     * 新增订单
     */
    @PostMapping
    public R add(@RequestBody ResOrder resOrder)
    {
        return R.toAjax(resOrderService.insertResOrder(resOrder));
    }

    /**
     * 修改订单
     */
    @PutMapping
    public R edit(@RequestBody ResOrder resOrder)
    {
        return R.toAjax(resOrderService.updateResOrder(resOrder));
    }

    /**
     * 删除订单
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resOrderService.deleteResOrderByIds(ids));
    }
}
